package com.seadragon.apps.doctorcard.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Type;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.vividsolutions.jts.geom.Point;

@Entity
@Table(name = "message")
public class Message implements Serializable {
	private static final long serialVersionUID = -6593318961554163616L;

	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = GenerationType.AUTO)
	protected long id;

	@Column(name="MEDIA_CONTENT")
	private String mediaContent;


	@Column(name="MEDIA_ICON_URL")
	private String mediaIconUrl;

	@Column(name = "LOCATION")
    @Type(type = "org.hibernate.spatial.GeometryType")
    private Point location;

	@JsonSerialize(using = DateSerializer.class)
	@Column(name="DATE_CREATED")
	private Date dateCreated;

	@ManyToOne
	@JoinColumn(name="AUTHOR_ID")
	private Contact author;
	
	@Transient
	private Contact publisher;
	
	@Column(name="MEDIA_TYPE")
	private String mediaType;
	
	public Message(){}
	
	public Message(long messageId){
		this.id = messageId;
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getMediaContent() {
		return mediaContent;
	}

	public void setMediaContent(String mediaContent) {
		this.mediaContent = mediaContent;
	}

	public String getMediaIconUrl() {
		return mediaIconUrl;
	}

	public void setMediaIconUrl(String mediaIconUrl) {
		this.mediaIconUrl = mediaIconUrl;
	}

	public Point getLocation() {
		return location;
	}

	public void setLocation(Point location) {
		this.location = location;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Contact getAuthor() {
		return author;
	}

	public void setAuthor(Contact author) {
		this.author = author;
	}

	public Contact getPublisher() {
		return publisher;
	}

	public void setPublisher(Contact publisher) {
		this.publisher = publisher;
	}

	public String getMediaType() {
		return mediaType;
	}

	public void setMediaType(String mediaType) {
		this.mediaType = mediaType;
	}

}
